package swna;
import java.util.*;
/*
 * Name:	FOClass
 * Author:	Bastian Stopp
 * Date:	12/08/2007
 * 
 * Function:
 * Handle Fan-In data of the given Fan-Out data.
 */
public class FOClass
{
	String ctype = new String("-");
	int nfanout;
	Vector<String> classes = new Vector<String>();

	
	FOClass()
	{
		nfanout = 0;
	}

	FOClass(String cname)
	{
		this.nfanout = 0;
	}


	/*
	 * Name:	setCtype
	 * Function:
	 * Sets the type of the class. (A / C / I)
	 * Parameter:
	 * ctype	Type of class
	 */
	void setCtype(String ctype)
	{
		this.ctype = ctype;
	}

	
	/*
	 * Name:	addClass
	 * Function:
	 * Adds a class that relies on the class of this object.
	 * Parameter:
	 * nclass	Name of the class that relies on this class.
	 * Return value:
	 * true, if class was added
	 * false, if class was already in the object.
	 */
	boolean addClass(String nclass)
	{
		// add a new class. check, whether it's yet in.
		boolean found = false;
		try
		{
			if (!classes.contains(nclass)) classes.add(nclass);
		}
		catch (Exception e)
		{
			System.out.println("***addClass: " + e);
		}
		return !found;
	}

	
	/*
	 * Name:	getCtype
	 * Function:
	 * Return the type of the class as string.
	 */
	String getCtype()
	{
		return this.ctype;
	}

	
	/*
	 * Name:	getClass
	 * Function:
	 * Return the name of the i-th class that relies on the class of this object.
	 * Parameter:
	 * i		The number of the relied class which name will be returned.
	 * Return value:
	 * The Name of the i-th relied class.
	 */
	String getClass(int i)
	{
		return this.classes.get(i);
	}

	
	/*
	 * Name:	getN
	 * Function:
	 * Return the number of the classes that rely on the class of this object.
	 */
	int getN()
	{
		return classes.size();
	}
}